﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace delegeteandevent
{
    //定义委托
    public delegate int Buy(string name);

    class delegatebuy
    {


        public int BuyApple(string name)
        {
            Console.WriteLine("{0}买苹果", name);
            return 10;
        }
        public int BuyOrange(string name)
        {
            Console.WriteLine("{0}买橘子", name);
            return 20;
        }
        public void WhoBuy(string name,Buy buy)
        {
            buy(name);
        }

    }
}
